/**
 * 
 */
package com.mvc.service.healthmanager.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSON;
import com.mvc.dao.BaseDaoI;
import com.mvc.model.base.ManangerInfo;
import com.mvc.model.base.Sport;
import com.mvc.model.healthmanager.archive.GroupManagerInfo;
import com.mvc.model.personHealth.ActivityAndDiet;
import com.mvc.service.healthmanager.PeopleGroupServiceI;

/**
 * @author Roy
 *
 */
@Service
public class PeopleGroupServiceImpl implements PeopleGroupServiceI{
	@Autowired
	private BaseDaoI<GroupManagerInfo> baseDaoI;
	
	
	@Override
	public ManangerInfo findGM(String personId, int sizes) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("personId", personId);
		List<GroupManagerInfo> gmi = baseDaoI.find("from GroupManagerInfo where personId='"+personId+"' order by id desc");
		if(gmi.size()<=0){
			return null;
		}
		ManangerInfo mi = new ManangerInfo();
		if(gmi.size()>0){
			/*身体运动信息*/
			Sport sport = JSON.parseObject(gmi.get(sizes).getSport(), Sport.class);
			BeanUtils.copyProperties(sport, mi);
		}
		return mi;
		
	}

}
